<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>演示ajax同步和异步</title>
</head>
<body>
<script type="text/javascript">
  window.onload = function (){
    document.getElementById("btn1").onclick = function (){
      //1.创建ajax核心对象
      var xhr = new XMLHttpRequest()
      //2.注册回调函数
      xhr.onreadystatechange = function (){
          if (this.readyState == 4) {
              if (this.status == 200) {
                  document.getElementById("div1").innerHTML = this.responseText
              }
          }
      }
      //3.开启通道
      xhr.open("GET","/ajax02/ajax_t_or_y_test?t="+new Date().getTime(),true)
      //4.发送请求
      xhr.send()
    }
  }
</script>
<button id="btn1">ajax请求1</button>
<div id="div1"></div>
<button id="btn2">ajax请求2</button>
<div id="div2"></div>
</body>
</html>